import Vue from 'vue'
import Router from 'vue-router'

//不是所有情况都需要异步加载组件
//异步加载只影响初始化性能渲染
const Protocol = resolve => require.ensure([], () => resolve(require('@/components/protocol')), 'protocol')
const Info = resolve => require.ensure([], () => resolve(require('@/components/info')), 'info')


const Attach = resolve => require.ensure([], () => resolve(require('@/components/imageUploader')), 'imageUploader')
const Progress = resolve => require.ensure([], () => resolve(require('@/components/progress')), 'Progress')
const Error = resolve => require.ensure([], () => resolve(require('@/components/error')), 'Error')
const Claim = resolve => require.ensure([], () => resolve(require('@/components/claim')), 'protocol')
//import Claim from '../components/claim.vue'
Vue.use(Router)

const routes = [
  {
    path: '/claim',
    name: 'claim',
    component: Claim
  },

  {
    path: '/protocol/:waybillNo',
    name: 'protocol',
    component: Protocol
  },
  {
    path: '/info/:waybillNo',
    name: 'info',
    component: Info
  },
  {
    path: '/attach/:waybillNo',
    name: 'attach',
    component: Attach
  },
  {
    path: '/progress/:waybillNo',
    name: 'progress',
    component: Progress
  },
  {
    path: '/error',
    name: 'error',
    component: Error
  }
]

const router = new Router({
  routes
})

export default router
